#include<iostream>
#include<cstring>
using namespace std;
const int N = 1e4 + 10;
int a[N];
int n;
int st, ed;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> st;
		cin >> n;
		memset(a, 0, sizeof(a));
		for (int i = 1; i <= n; i++) {
			int x;
			cin >> x;
			a[x] = 1;
		}
		int ans = 0;
		cin >> ed;
		for (int i = st; i <= ed; i++) {
			if (!a[i]) {
				ans++;
			}
		}
		cout << ans << endl;
		
	}
	return 0;
}